<{include file="public/header.html"}>
 
<script language="javascript">
<!--
if (Ext.form.ComboBox) {
    Ext.apply(Ext.form.ComboBox.prototype, {
        triggerAction:'all',
        selectOnFocus:true,
        editable:false,
        mode:'local',
        lazyInit:false,
        valueField:'sValue',
        displayField:'sText'
    });
}
function selectScale(comb,record,index) {
    var sHourInterval = Ext.getCmp("sHourInterval");
    if (record.get("sValue") == "GANTT_HHOUR") {
        sHourInterval.enable();
    } else {
        sHourInterval.disable();
    }
}
var ganttPanel = new Ext.Panel({
    frame :true,
    title :"项目甘特图",
    layout:'form',
    region:'center',
    autoLoad:"./taskGantt.php",
    autoScroll:true,
    //html:"<img src='/book99/images/bk.jpg' />",

    tbar:['甘特图查询条件:', '-', '最小时间单位:',
    {
        xtype:"combo",id:'sScaleType',value:"GANTT_HDAY",width:80,
        displayField:'sText',valueField:'sValue',
        listeners:{'select':selectScale},
        store:new Ext.data.SimpleStore({
              data:[['GANTT_HYEAR','年'],['GANTT_HMONTH','月'],
              ['GANTT_HWEEK','周'],["GANTT_HDAY","日"],["GANTT_HHOUR","时"]],
              fields:['sValue','sText']
         })
    }, '-', '时间间隔:',{
        xtype:"combo",id:'sHourInterval',value:"",width:80,
        displayField:'sText',valueField:'sValue',disabled:true,
        store:new Ext.data.SimpleStore({
              data:[['1','1小时'],['2','2小时'],['3','3小时'],["4","4小时"],
              ['6','6小时'],["8","8小时"],["12","12小时"]],
              fields:['sValue','sText']
         })
    }, '-', {
        xtype:'checkbox',hideLabel:true,boxLabel:'设定日期范围:',
        checked:false,id:"isSetDate",
        listeners:{'check':function(chkbox,checked) {
            if (checked) {
                Ext.getCmp("sStartDate").enable();
                Ext.getCmp("sEndDate").enable();
            } else {
                Ext.getCmp("sStartDate").disable();
                Ext.getCmp("sEndDate").disable();
            }
        }}
    }, ' 从 ',{
        xtype:"datefield",id:'sStartDate',disabled:true,width:90
    }, ' 到 ',{
        xtype:"datefield",id:'sEndDate',disabled:true,width:90
    },'-',{
        xtype:"button",id:'btnLoad',tooltip:"刷新或查询甘特图",width:150,
        text:"刷新或查询", iconCls:'btn_refresh',
        handler:refreshGantt
    }]
});
var viewport = new Ext.Viewport({
    layout: 'border',
    items : ganttPanel
});

function refreshGantt() {
    var checkbox = Ext.getCmp("isSetDate");

	if (checkbox!=null && checkbox.checked) {
        var sStartDate = Ext.getCmp("sStartDate").getValue();
        var sEndDate = Ext.getCmp("sEndDate").getValue();
	
        if (sStartDate == "") {
            Ext.Msg.alert('错误提示','时间范围设置不正确，开始日期不能为空！');
            return false;
        }
        if (sEndDate == "") {
            Ext.Msg.alert('错误提示','时间范围设置不正确，结束日期不能为空！');
            return false;
        }
        if (sStartDate >= sEndDate) {
            Ext.Msg.alert('错误提示','时间范围设置不正确，开始日期必须小于结束日期');
            return false;
        }
    }
    ganttPanel.load({
        url:'./taskGantt.php',
        params:{strScaleType:Ext.getCmp("sScaleType").getValue(),
            strHourInterval:Ext.getCmp("sHourInterval").getValue(),
            strDateRange:(Ext.getCmp("isSetDate").checked?"1":"0"),
            strStartDate:Ext.getCmp("sStartDate").value,
            strEndDate:Ext.getCmp("sEndDate").value}
    });
}
function maplink(taskid) {
    var url = "task/taskinfo.php?strTaskID="+taskid;
    TabUtil.openTab("taskinfo","查看任务计划",url);
}

//-->
</script>

<{include file="public/footer.html"}>